package com.handu.luna.core.domain.promotion;

import com.handu.luna.core.domain.BaseRepository;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * Created by wangzailiang on 2014/6/27.
 */

public interface PostCardRepository extends BaseRepository<PostCard> {

    @Query("select c from PostCard c where c.postCardPromotionId = ?1 order by c.createdDate desc")
    public Page<PostCard> findAllByPostCardPromotionId(Long postCardPromotionId, Pageable pageable);

    @Query("select c from PostCard c where c.postCardPromotionId = ?1 order by c.createdDate desc")
    public List<PostCard> findAllByPostCardPromotionId(Long postCardPromotionId);

    @Modifying
    @Query("delete PostCard c where c.postCardPromotionId = ?1")
    public void deleteByPostCardPromotionId(Long postCardPromotionId);
}
